@extends('base')

@section('content')
    <div class="layui-card">
        <div class="layui-card-header layuiadmin-card-header-auto">
            <form class="layui-form" action="{!! route('crm.customer') !!}">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label for="" class="layui-form-label">客户编号：</label>
                        <div class="layui-input-block" style="width: 275px">
                            <input type="text" name="uuid" placeholder="请输入客户编号" class="layui-input" >
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label for="" class="layui-form-label">联系电话：</label>
                        <div class="layui-input-block" style="width: 275px">
                            <input type="text" name="contact_phone" placeholder="请输入联系电话" class="layui-input" >
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button type="button" lay-submit lay-filter="search" class="layui-btn layui-btn-sm" >搜索</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-card-body">
            <table id="dataTable" lay-filter="dataTable"></table>
        </div>
    </div>
@endsection

@section('script')
    <script>
        layui.use(['layer','table','form','laydate','dropdown'],function () {
            var $ = layui.jquery;
            var dropdown = layui.dropdown
            var layer = layui.layer;
            var form = layui.form;
            var table = layui.table;
            var laydate = layui.laydate;
            //用户表格初始化
            var dataTable = table.render({
                elem: '#dataTable'
                ,height: 'full'
                ,url: "{!! route('crm.customer') !!}" //数据接口
                ,page: true //开启分页
                ,cols: [[ //表头
                    {field: 'uuid', title: '客户编号'}
                    ,{field: 'name', title: '客户名称'}
                    ,{field: 'contact_phone', title: '联系电话'}
                    ,{field: 'type_name', title: '分类'}
                    ,{field: 'node_name', title: '当前进度'}
                    ,{field: 'follow_user_nickname', title: '跟进人',width:100}
                ]]
            });

            table.on('row(dataTable)', function(obj){
                var parent$ = window.parent.layui.jquery;
                parent$("#customer_tips").text("客户编号："+obj.data.uuid+"，客户名称："+obj.data.name)
                parent$("#customer_id").val(obj.data.id)
                parent.layer.closeAll()
            });

        })
    </script>
@endsection
